import Vue from 'vue'
import App from './App'
import http from '@/utils/http.js'
import { showLoad,hideLoad } from '@/utils/common.js';

// 注册全局组件
const msg = (title, duration=1500, mask=false, icon='none')=>{
	//统一提示方便全局修改
	if(Boolean(title) === false){
		return;
	}
	uni.showToast({
		title,
		duration,
		mask,
		icon
	});
}

const prePage = ()=>{
	let pages = getCurrentPages();
	let prePage = pages[pages.length - 2];
	// #ifdef H5
	return prePage;
	// #endif
	return prePage.$vm;
}
// 过万的处理(添加公用过滤器，页面无需再添加，直接用管道符（ | ）链接添加即可)
Vue.filter("outThousand",(value)=>{
	if (value > 99999) {
	  value = (Math.round(value / 1000) / 10).toFixed(1) + "w";
	}
	return value;
})

Vue.config.productionTip = false
Vue.prototype.$fire = new Vue();
Vue.prototype.$HTTP = http;
Vue.prototype.$showLoad = showLoad;
Vue.prototype.$hideLoad = hideLoad;
Vue.prototype.$api = {msg, prePage};
App.mpType = 'app'

const app = new Vue({
    ...App
})
app.$mount()

// #ifdef VUE3
import { createSSRApp } from 'vue'
export function createApp() {
  const app = createSSRApp(App)
  return {
    app
  }
}
// #endif